using System;
using System.Data;
using System.Collections.Generic;
using System.Text;

using PickGold;
using PickGold.Database;

namespace PickGold.Entities.Table
{
    public class CLogPageInfo : CLogTable
    {
        //
        public const string ENTITY_NAME = "tl_sys_page_info";
        public const string ENTITY_ALIAS = "page_log";
        //
        public const string ONLINE_ID = CBaseUserOnline.ENTITY_KEY;
        public const string USER_BOSS = "user_boss";
        public const string USER_SPACE = "user_space";
        public const string USER_ID = CBaseUserInfo.ENTITY_KEY;
        public const string PAGE_URL = "page_url";
        public const string PAGE_TITLE = "page_title";
        public const string PAGE_REFERER = "page_referer";
        public const string QUERY_COUNT = "query_count";
        public const string RUN_TIMESLICE = "run_timeslice";
        //
        private SLogPageInfo _ = null;
        //
        public CLogPageInfo() : base(ENTITY_NAME, ENTITY_ALIAS) { }
        public CLogPageInfo(CDatabase db) : base(db, ENTITY_NAME, ENTITY_ALIAS) { }
        public CLogPageInfo(string alias) : base(ENTITY_NAME, alias) { }
        public CLogPageInfo(CDatabase db, string alias) : base(db, ENTITY_NAME, alias) { }
        //
        protected override void SetSchema()
        {
            this.SetSchema(new SLogPageInfo());
        }
        protected void SetSchema(SLogPageInfo s)
        {
            this._ = null;
            base.SetSchema(s);
        }
        //
        protected override void PreInitSchema()
        {
            this._DataTable.Columns.Add(ONLINE_ID, typeof(long)).DefaultValue = this._.OnlineID;
            this._DataTable.Columns.Add(USER_BOSS, typeof(long)).DefaultValue = this._.UserBoss;
            this._DataTable.Columns.Add(USER_SPACE, typeof(long)).DefaultValue = this._.UserSpace;
            this._DataTable.Columns.Add(USER_ID, typeof(long)).DefaultValue = this._.UserID;
            this._DataTable.Columns.Add(PAGE_URL, typeof(string)).MaxLength = 256;
            this._DataTable.Columns.Add(PAGE_TITLE, typeof(string)).MaxLength = 256;
            this._DataTable.Columns.Add(PAGE_REFERER, typeof(string)).MaxLength = 256;
            this._DataTable.Columns.Add(QUERY_COUNT, typeof(int)).DefaultValue = this._.QueryCount;
            this._DataTable.Columns.Add(RUN_TIMESLICE, typeof(double)).DefaultValue = this._.RunTimeslice;
        }
        //
        #region Property
        //
        public long OnlineID
        {
            set
            {
                this._.OnlineID = value;
                this.SetValue(ONLINE_ID, value);
            }
            get
            {
                return this._.OnlineID;
            }
        }
        //
        public long UserBoss
        {
            set
            {
                this._.UserBoss = value;
                this.SetValue(USER_BOSS, value);
            }
            get
            {
                return this._.UserBoss;
            }
        }
        //
        public long UserSpace
        {
            set
            {
                this._.UserSpace = value;
                this.SetValue(USER_SPACE, value);
            }
            get
            {
                return this._.UserSpace;
            }
        }
        //
        public long UserID
        {
            set
            {
                this._.UserID = value;
                this.SetValue(USER_ID, value);
            }
            get
            {
                return this._.UserID;
            }
        }
        //
        public string PageUrl
        {
            set
            {
                this._.PageUrl = value;
                this.SetValue(PAGE_URL, value);
            }
            get
            {
                return this._.PageUrl;
            }
        }
        //
        public string PageTitle
        {
            set
            {
                this._.PageTitle = value;
                this.SetValue(PAGE_TITLE, value);
            }
            get
            {
                return this._.PageTitle;
            }
        }
        //
        public string PageReferer
        {
            set
            {
                this._.PageReferer = value;
                this.SetValue(PageReferer, value);
            }
            get
            {
                return this._.PageReferer;
            }
        }
        //
        public int QueryCount
        {
            set
            {
                this._.QueryCount = value;
                this.SetValue(QUERY_COUNT, value);
            }
            get
            {
                return this._.QueryCount;
            }
        }
        //
        public double RunTimeslice
        {
            set
            {
                this._.RunTimeslice = value;
                this.SetValue(RUN_TIMESLICE, value);
            }
            get
            {
                return this._.RunTimeslice;
            }
        }
        //
        #endregion
        //
        public override bool MoveTo(int position)
        {
            if (!base.MoveTo(position))
                return false;
            this._.OnlineID = this.GetValue<long>(ONLINE_ID);
            this._.UserBoss = this.GetValue<long>(USER_BOSS);
            this._.UserSpace = this.GetValue<long>(USER_SPACE);
            this._.UserID = this.GetValue<long>(USER_ID);
            this._.PageUrl = this.GetValue<string>(PAGE_URL);
            this._.PageTitle = this.GetValue<string>(PAGE_TITLE);
            this._.PageReferer = this.GetValue<string>(PAGE_REFERER);
            this._.QueryCount = this.GetValue<int>(QUERY_COUNT);
            this._.RunTimeslice = decimal.ToDouble((decimal)this._DataRow[RUN_TIMESLICE]);
            return true;
        }
        //
    }
    //
    public class SLogPageInfo : SLogTable
    {
        //
        public long OnlineID = -1;
        public long UserBoss = -1;
        public long UserSpace = -1;
        public long UserID = -1;
        public string PageUrl = null;
        public string PageTitle = null;
        public string PageReferer = null;
        public int QueryCount = 0;
        public double RunTimeslice = 0;
        //
    }
    //
}
//
